﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace erpWebapiBack.Util
{
    public class Config
    {
        /// <summary>
        /// 根据Key取Value值
        /// </summary>
        /// <param name="key"></param>
        public static string GetValue(string key)
        {
            if (ConfigurationManager.AppSettings[key].IsEmpty())
            {
                return "";
            }
            return ConfigurationManager.AppSettings[key].ToString().Trim();
        }

        /// <summary>
        /// 依据key获取数据库连接地址
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string GetConnValue(string key)
        {
            if (ConfigurationManager.ConnectionStrings[key].ConnectionString.IsEmpty())
            {
                return "";
            }
            return ConfigurationManager.ConnectionStrings[key].ConnectionString.Trim();
        }
    }
}
